home *** CD-ROM | disk | FTP | other *** search
/ World of Education / World of Education.iso / world_p / pcshx10b.zip / PCSHX10B.EXE / UTILS.EXE / UTILDOCS.EXE / FINREP.DOC < prev    next >
Text File  |  1991-10-30  |  12KB  |  259 lines

  1.                    FINREP.DOC  DOS Version 1.0
  2.                            05/26/86
  3.  
  4. Eric Gans
  5. French Department, UCLA
  6. Los Angeles, CA 90024
  7.  
  8.  
  9.      FINREP is a search/replace program that remedies most of the
  10. deficiencies of Wordstar's ^QA and other similar commands.  Aside
  11. from being faster, it has important additional features:
  12.  
  13.      - allows wildcards in search string 
  14.      - allows wildcard filename (find/replace in groups of files)
  15.      - command-line entry allows easy inclusion in BAT files 
  16.      - allows entry of control or hex characters (0-FF)
  17.      - can be used with object files (e.g., COM files)
  18.      - sets  capitalization (first letter or whole word) and high
  19.        bit of the last character according to the old string
  20.  
  21. This last feature means that,  for example,  if you are writing a 
  22. scenario where the characters' names appear sometimes in CAPS and 
  23. sometimes just Capitalized, you don't need two search/replaces to 
  24. replace one name with another: JOE will be replaced by HARRY, Joe 
  25. by Harry, and even joe by harry.  
  26.  
  27.                               *****
  28.  
  29. Format: finrep [d:]fn [newfn] /[switches]/ oldstring [newstring]
  30.  
  31. (Enter "finrep" alone for a brief command summary.)
  32.  
  33. If a second filename is given, the changes will be placed in that
  34. file;  if  not,  the  old filename will hold the changes and  the
  35. original  file will be changed from fn.ft to fn.BAK  (unless  the
  36. "B" switch is used).
  37.  
  38. Wildcards  (*,?) may be used anywhere in the filename;  if  there 
  39. are  wildcards in the filetype (after the ".") the B switch  will
  40. be  set  automatically  to suppress creation  of  BAK  files.  If 
  41. wildcards are used,  a second filename cannot be entered.  If you 
  42. enter:
  43.  
  44. A>finrep urk*.doc // "blurk" "zap"
  45.  
  46. the files urk01.doc,  urk33.doc,  urktty.doc would be modified as 
  47. expected and files urk01.bak, urk33.bak etc. would be created.
  48.  
  49. The characters "//" must be entered even if no switches are used.
  50.  
  51. The switches are as follows:
  52.  
  53. B  =  no BAK file.  This switch disables making a BAK  file;  the 
  54. original  file  will be lost.  (Use only if you did not  enter  a 
  55. second filename.)
  56.  
  57. Q = allow wildcards in search string. (The program runs faster if 
  58. this  switch is not used.)  The various options for this  command 
  59. are described below.
  60.  
  61. V = verify replacement.   If this switch is used,  the context of 
  62. the search string will be displayed on the screen and you will be 
  63. queried  re replacement.   This switch cannot be used along  with 
  64. the O or H switches (see below).
  65.  
  66. O = Object file.  If this switch is used, the program will ignore 
  67. end-of-file  markers (1AH),  as in  COPY's /B switch.   Use   for 
  68. search/replace in non-text files.   WARNING: if you don't use "O" 
  69. with  a  non-text  file it will be cut off after the  first  1AH. 
  70. That's why FINREP makes BAK files!
  71.  
  72. H  =  keep High bit.  With this switch,  all bytes  are  searched 
  73. exactly  as they are;  letters with the high bit set will not  be 
  74. identified  with their standard ASCII  counterparts.  
  75.  
  76. W = no Whole-word search.  This switch is used to search a string 
  77. whether  or not it is a whole word;  with it,  a search for "the" 
  78. will find "other", "their" etc.
  79.  
  80. NB  - The  program  defines a "word"  as  anything  preceded  and 
  81. followed  by  something other than a letter  (space,  punctuation 
  82. mark,  number, control character, beginning or end of file). Thus 
  83. this  switch  is not needed if the search string is a  series  of 
  84. words,  a  word  preceded  by a control  character  that  is  not 
  85. continguous to another word, etc.
  86.  
  87. C  = respect case.  This switch allows you to distinguish capital 
  88. from lower-case letters: in a search for "the", "The" will not be 
  89. found/replaced.  (NB: Upper case letters cannot be entered within 
  90. quotes; see below.)
  91.  
  92.  
  93. In normal operation (with no switches),  the search will  include 
  94. whole words only; it will ignore case and high bits, but will set 
  95. the  new  string  to  correspond  to the  old  in  this  respect, 
  96. capitalizing the first letter or the whole string and setting the 
  97. high  bit  of the last as required.  This last  feature  is  only 
  98. useful if the replacement string is one word long; if it contains 
  99. more than one word,  you may set the high bits when you enter the 
  100. string,  or let your word-processor (e.g. Wordstar) do it. If you 
  101. include  capitals  in  your  replacement  string,  they  will  be 
  102. respected even if the find string is not capitalized.
  103.  
  104. If  you want to search for a capitalized word,  you must use  the 
  105. "C"  switch (or the "H" or "O" switch);  FINREP will give you  an 
  106. error message if you don't. 
  107.  
  108. The last four switches are in the relation O > H > C       
  109.                                                  > W  ; 
  110. the "higher" switch includes the smaller.  Thus if the "H" switch 
  111. is used,  capitals and lower case will be distinguished,  and the 
  112. search will not be limited to whole words.
  113.  
  114. *****************************************************************
  115.  
  116. String entry:
  117.  
  118. The  find  and replace strings must be separated by a space  from 
  119. the switch entry and from each other.  Strings should be  entered 
  120. as follows:
  121.  
  122. ASCII     - in quotes: "blurk", "54%**90er @"
  123.  
  124. The following characters must NOT be placed between quotes:
  125.  
  126. HEX       - separate by commas: d,1A,cd,10,ff,3 
  127. CAPITALS  - between !!: !A!,!hello!          
  128. CONTROL CHARACTERS - preceded by ^: ^M,^m^j,^c,^C,^[,^^
  129. WILDCARDS - ????, ?n (1 <= n <= 9) or ?* (indeterminate)
  130.      The  "+" character is used to display a break in the replace 
  131. string (see below).
  132.  
  133. All ascii letters entered within quotes will be treated as  LOWER 
  134. CASE.  If  you  want  to search upper case letters with  the  "C" 
  135. switch,  or to put upper case letters in the replace string,  you 
  136. must  surround  them  with "!!",  unless you enter  them  as  hex 
  137. characters:  (A = 41, B = 42 ...). 
  138.  
  139. Any  combination  of characters is  valid;  for  clarity,  groups 
  140. should  be separated by commas,  although this is only  necessary 
  141. for individual hex characters: !h!"ello",^m^j,e5,?7,32,!blurk!,^q 
  142. Quotes and !..!  must be closed.  To search/replace the quotation 
  143. mark,  enter it as a hex character ("=22h).   You can search  for 
  144. "!" if you keep it between quotes.
  145.  
  146. The  length  of the find/replace strings is limited to 30  bytes; 
  147. this  length  applies to the strings themselves and  not  to  the 
  148. keyboard entry,  which cannot exceed 127 bytes in all (blame  DOS
  149. for  this).  Thus  ^j,cd,ff,3d is 4 bytes long.   In the case  of 
  150. indeterminate  wildcards,  up to 255 bytes are allowed,  but  the 
  151. limit of 30 still stands for the find/replace strings themselves.
  152.  
  153. If  you do not enter a replace string,  the  searched-for  string 
  154. will be replaced by nothing, i.e., deleted.
  155.  
  156. WILDCARDS 
  157. The wildcard search has a great deal of flexibility.  For obvious 
  158. reasons,  wildcards cannot appear at the beginning of the  search 
  159. string.  The options are as follows:
  160.  
  161. 1. Simple wildcard search: all bytes of the search string will be 
  162. replaced.
  163.  
  164. finrep  zz.txt  /q/ "d"?2"e" "xxyz" will replace all  words  like 
  165. "done", "dare", "dove" etc. by "xxyz"  A maximum of four wildcard 
  166. groups are allowed in this form: thus "a"?"cd"?4"ijk"??"nopq"?"s" 
  167. is a permissible search string
  168.  
  169. 2.  Simple wildcard search with break. Only one wildcard group is 
  170. allowed;  the  replace string is divided in two,  with the  first 
  171. part  replacing  what precedes the wildcards and the second  what 
  172. follows;  the  intermediate bytes are left alone.   The break CAN 
  173. appear at the beginning or end of the replace string to  indicate 
  174. that  the corresponding part of the find string is to be deleted.  
  175. A blank replace string (entered simply as: + ) will delete both.
  176.  
  177. finrep  xx.txt /qw/ "d"?2"e" "xx"+"yzz" will replace the  "d"  in 
  178. this  pattern  with "xx" and the "e" with "yzz";  "done"  becomes 
  179. "xxonyyz", "madame" -> "maxxamyxx", etc.  (This last example only 
  180. works if the "W" switch is used.)
  181.  
  182. 3.  Indeterminate  wildcard  search/replace.   The  indeterminate 
  183. wildcard "?*" must be the only wildcard in the search string.  In 
  184. this  option  the  whole  string from the  beginning  to  end  is 
  185. replaced.   A  maximum of 255 characters will be allowed  in  the 
  186. search string; longer strings will not be found.
  187.  
  188. finrep  blurk.let  /qw/  "xy"?*"zq" "garbage"  will  replace  all 
  189. strings   beginning  and  ending  with  the  indicated   letters: 
  190. "xyrwerwerzq",  "xyuu  is  the nbrzq",  "xy ^C^Yzq" will  all  be 
  191. replaced by "garbage"
  192.  
  193. 4.  Indeterminate  wildcard with break.  This is a very  powerful 
  194. option  that allows you,  for example,  to replace  PerfectWriter 
  195. "fences" with WordStar control toggles (& vice versa). Here again 
  196. only  one  wildcard group is allowed in the  search  string;  the 
  197. intermediate bytes are left unchanged.
  198.  
  199. finrep   zap.kkk   /qw/   "123"?*"45"  "6"+"789"   will   replace 
  200. "zz123blurk blurk xxxc oo45rr" by "zz6blurk blurk xxxc oo789rr";
  201. finrep  perf.wri /qwc/ "@"!ux!"{"?*"}" ^s+^s will replace the  PW 
  202. underline fence @UX{ ...  } by WS's ^S ...  ^S  Note that the "C" 
  203. flag is used here to search for caps; if l.c. as well as caps are 
  204. acceptable,  it  could be omitted and the search  string  written 
  205. "@ux{"?*"}".   You  can delete the fences altogether by replacing 
  206. the ^s+^s by + in the last example.
  207.  
  208. One  user thought the word "break" was misleading and  should  be 
  209. replaced  by  "save," since the "+" in the replace  string  means 
  210. that  you  preserve the wildcard part of the  search  string.  In 
  211. other words:  finrep zap.txt /qw/ "<<"?*">>" will kill everything 
  212. between  the "<<..>>" whereas:  finrep zap.txt /qw/ "<<"?*">>"  +
  213. will just kill the "<<>>" and "save" their contents.  
  214.  
  215. FINREP  can be aborted at any time by typing <ESC>. 
  216.  
  217. Except when the "V" switch is used, the only screen output is the 
  218. number of strings replaced and, if you use wildcards, the names & 
  219. total  number  of  files  processed.  If  you  want  to  see  the 
  220. replacement procedure in action, use a word-processor!
  221.  
  222. Notes:
  223.  
  224. 1.  FINREP  will modify files of any length;  it uses the  entire 
  225. segment below  FF00H  as its buffer,  and writes to disk whenever 
  226. the  buffer  fills up.
  227.  
  228. 2.  There  is no intrinsic limit on the number of  files  allowed 
  229. under the wildcard filename option;  for sanity's sake,  you will 
  230. get an error message if there are more than 255.
  231.  
  232. 3.  If  you want to create a version of FINREP with some  of  the 
  233. switches preset,  run the program under DEBUG without a filename:      
  234. debug finrep.com /[sw1][sw2]/ and rewrite it when it  terminates. 
  235. This procedure  is  NOT  REVERSIBLE,  so  change the name  before 
  236. you write the file and keep  your  original  FINREP unchanged.
  237.  
  238. 4.  In deciding whether to capitalize a whole word/string, FINREP 
  239. looks  at the first two letters.  If the find string has only one 
  240. letter,  only the first letter of the replacement string will  be 
  241. capitalized.   If   the   word  to  be   replaced   has   unusual 
  242. captalization (e.g.  BBrrOOOmm),  use the "C" switch and/or enter 
  243. separate replacement strings for different variants.
  244.  
  245. 5.   In using indeterminate wildcards, you should usually use the 
  246. "W"  switch,  since  without it BOTH HALVES of the search  string 
  247. must  begin and end on word boundaries.   This is only likely  if 
  248. you are replacing whole words.
  249.  
  250.                               *****
  251.  
  252. FINREP  is  a  translation of  my CP/M program of the  same  name 
  253. (v2.2),  and in this first version at least has retained some  of 
  254. the  limitations of the original (no pathnames,  sector by sector 
  255. disk reads/writes).  Nonetheless, I haven't seen anything yet for 
  256. DOS  with the equivalent power and versatility.   Please  let  me 
  257. know  if you find bugs and/or if you can think of future areas of 
  258. improvement.
  259.